import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// 公共路由
export const constantRoutes = [
  {
    path: '/',
    redirect: 'full',
  },
  {
    path: '/full',
    component: () => import('@/views/useFull'),
    hidden: true
  },
  {
    path: '/withoutTree',
    component: () => import('@/views/withoutTree'),
    hidden: true
  },
  {
    path: '/bimface',
    component: () => import('@/views/useBimface'),
    hidden: true
  }
]

// 防止连续点击多次路由报错
const routerPush = Router.prototype.push
const routerReplace = Router.prototype.replace
// push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err)
}
// replace
Router.prototype.replace = function push(location) {
  return routerReplace.call(this, location).catch(err => err)
}

export default new Router({
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
